<?php 

$username = $_POST['username'];

$preg = "/^[a-z][a-z0-9]{5,7}$/";

$c= preg_match($preg, $username);

if(!$c){
	$returnarr = array(
		'error'=>1,
		'info'=>"用户名不符合要求，必要是6-8位"
		);
	echo json_encode($returnarr);
}else{


	$user = include './user.php';

	foreach ($user as $v) {
		if($v['username']==$username){
			$returnarr = array(
				'error'=>1,
				'info'=>"用户名已存在，请重新输入"
				);
			echo json_encode($returnarr);
			exit;
		}
	}
	
	$returnarr = array(
		'error'=>0,
		'info'=>"用户名符合要求,可以用"
		);
	echo json_encode($returnarr);

}













 ?>